﻿<%@ Page Title="Manage Account" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Manage.aspx.cs" Inherits="AjaxChatWebApp.Account.Manage" %>
<%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %>
<%@ Import Namespace="Microsoft.AspNet.Membership.OpenAuth" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <script>
        function readURL(input, imgFrame) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();
                reader.onload = function (e) {
                    $("#" + imgFrame)
                        .attr('src', e.target.result)
                        .width(100)
                        .height(100);
                };

                reader.readAsDataURL(input.files[0]);
            }
        }
     </script>
        <h2>Manage account</h2>

                    <p class="validation-summary-errors">
                        <asp:Literal runat="server" ID="ErrorMessage" />
                    </p>

                    <fieldset>
                        <legend>Registration Form</legend>
                        <ol>
                            <li>
                                <asp:Label ID="Label5" runat="server" AssociatedControlID="tbFirstname">First Name</asp:Label>
                                <asp:TextBox runat="server" ID="tbFirstName" />
                            </li>
                            <li>
                                <asp:Label ID="Label6" runat="server" AssociatedControlID="tbLastName">Last Name</asp:Label>
                                <asp:TextBox runat="server" ID="tbLastName" />
                            </li>
                            <li>
                                <asp:Label ID="Label1" runat="server" AssociatedControlID="tbCurrentPassword">Current Password</asp:Label>
                                <asp:TextBox runat="server" ID="tbCurrentPassword" TextMode="Password" ValidationGroup="main"/>
                            </li>
                            <li>
                                <asp:Label ID="Label3" runat="server" AssociatedControlID="tbNewPassword">New Password</asp:Label>
                                <asp:TextBox runat="server" ID="tbNewPassword" TextMode="Password" ValidationGroup="main"/>
                            </li>
                            <li>
                                <asp:Label ID="Label4" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm new password</asp:Label>
                                <asp:TextBox runat="server" ID="ConfirmNewPassword" TextMode="Password" ValidationGroup="main"/>
                                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="tbNewPassword" ControlToValidate="ConfirmNewPassword"
                                     CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The password and confirmation password do not match." ValidationGroup="main"/>
                            </li>
                            <li>
                                <asp:Label ID="Label2" runat="server" AssociatedControlID="fuAvatar">Avatar</asp:Label>
                                <asp:Image ID="imgAvatar" ImageUrl="../Avatars/defaultAvatar.png" 
                                            Width="100px" Height="100px" BorderStyle="Solid" 
                                            runat="server" BackColor="White" BorderColor="Gray" BorderWidth="1px" />
                                <br />
                                <asp:FileUpload ID="fuAvatar" onchange="readURL(this, 'MainContent_imgAvatar');" runat="server"/>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="fuAvatar"
                                                                     CssClass="field-validation-error" Display="Dynamic"
                                                                     ErrorMessage="Only .gif .jpg .png .tiff are allowed" 
                                                                     ValidationExpression="(.*\.([Gg][Ii][Ff])|.*\.([Jj][Pp][Gg])|.*\.([pP][nN][gG])|.*\.([tT][iI][iI][fF])$)">
                                </asp:RegularExpressionValidator>
                            </li>
                        </ol>
                        <asp:Button ID="btUpdate" runat="server" Text="Update" OnClick="btUpdate_Click" ValidationGroup="main"/>
                    </fieldset>
</asp:Content>
